import Vue from 'vue'
import Router from 'vue-router'
import dashboard from '../views/post/dashboard'
import userinfo from '../views/user/userInfo'
import postBody from '../views/post/postBody'
import adminDashboard from '../views/admin/adminDashboard'
import adminInform from '../views/admin/inform/index'
import informRecord from '../views/admin/inform/handleRecord'
import adminPost from '../views/admin/post/index'
import PostRecord from '../views/admin/post/handleRecord'
import adminUser from '../views/admin/user/index'
import adminComment from '../views/admin/comment/index'
Vue.use(Router)
// 获取原型对象上的push函数
const originalPush = Router.prototype.push
// 修改原型对象中的push方法
Router.prototype.push = function push (location) {
  return originalPush.call(this, location).catch(err => err)
}
export default new Router({
  mode: 'history',
  routes: [
    {
      path: '/',
      name: 'dashboard',
      component: dashboard
    },
    {
      path: '/userinfo',
      name: 'userinfo',
      component: userinfo
    },
    {
      path: '/postBody',
      name: 'postBody',
      component: postBody
    },
    {
      path: '/adminDashboard',
      name: 'adminDashboard',
      component: adminDashboard,
      children: [
        {
          path: 'adminInform',
          name: 'adminInform',
          component: adminInform
        },
        {
          path: 'informHandleRecord',
          name: 'handleRecord',
          component: informRecord
        },
        {
          path: 'adminPost',
          name: 'adminPost',
          component: adminPost
        },
        {
          path: 'PostHandleRecord',
          name: 'PostHandleRecord',
          component: PostRecord
        },
        {
          path: 'adminUser',
          name: 'adminUser',
          component: adminUser
        },
        {
          path: 'adminComment',
          name: 'adminComment',
          component: adminComment
        }
      ]
    }
  ]
})
